package lib

//link to  77 90
func init() {
	Probs = append(Probs, Problem{
		Num:         78,
		Discription: "无重复元素数组的子集",
		Level:       2,
		Labels: map[string]int{
			"递归": 1,
			"去重": 1,
		},
	})
}

func Subsets(nums []int) [][]int {
	res := [][]int{{}}
	comb := make([]int, 0)

	var travel func(int)
	travel = func(start int) {
		if start >= len(nums) {
			return
		}

		for i := start; i < len(nums); i++ {
			comb = append(comb, nums[i])
			res = append(res, append([]int(nil), comb...))
			travel(i + 1)
			comb = comb[:len(comb)-1]
		}
	}

	travel(0)
	return res
}
